<template>
  <div >
    <div :class="['header',{brandHeader:false}]" ref="headerBox">
        <div :class="['left',{absolutionLeft:absolutionLeft}]">
          <a href="javascript:;">
            <i :class="[imgName]" @click="fn"></i>
          </a>
        </div>
        <div class="title">
          <slot >{{msg}}</slot>
        </div>
        <div class="right" v-if="show3">
          <a href="#" v-if="show2">
            <i :class="[imgRight1]" @click="fn"></i>
          </a>
          <a href="javascript:;" class="one-right" v-if="show">
            <i :class="[imgRight2]" @click="fn"></i>
          </a>
        </div>
      </div>
  </div>

</template>

<script>
  import bus from '../bus'

  export default {
    data() {
      return {
          show:true,
          show2:true,
          show3:true,
        absolutionLeft:true
      }
    },
    props:{
      msg:String,
      imgName:String,
      imgRight1:String,
      imgRight2:String
    },
    created(){
      if(this.imgRight1 == 'goIndex'){
        this.show = false;
        this.$nextTick(()=>{
          this.$refs.headerBox.style.background ="transparent"
          this.$refs.headerBox.style.position ="relative"
          this.$refs.headerBox.style.border = "none"

        })
      }
      if(this.imgName == 'close'){
        this.$nextTick(()=>{
          this.show3 = false;
          this.absolutionLeft = true
        })
      }
     this.$nextTick(()=>{
       if(this.imgRight2 == 'share'){
         this.$refs.headerBox.style.position = 'relative'
       }
     })
    },

    computed:{

    },
    methods:{
      fn(){
        if(this.imgName == 'arrow-left'){
          this.$router.go(-1)
        }
        if(this.imgRight1 == 'goIndex'){
          this.$router.replace({
            path:'/'
          })
        }
        if(this.imgName == 'close'){
          bus.$emit('closeList');
        }

        this.$emit('close');

      }
    }
  }
</script>

<style scoped type="text/css" rel="stylesheet/sass" lang="scss">
  @import "../common/style/scss/header.scss";


</style>
